package common

import (
	"jlpay-sdk-go/pkg/jlpay/core"
	"jlpay-sdk-go/pkg/jlpay/models/trans/common"
	"jlpay-sdk-go/pkg/jlpay/services"
)

// PreAuthCloseService 预授权关闭服务
type PreAuthCloseService struct {
	*services.BaseService
}

// NewPreAuthCloseService 创建预授权关闭服务
func NewPreAuthCloseService(config *core.Config) *PreAuthCloseService {
	return &PreAuthCloseService{
		BaseService: services.NewBaseService(config),
	}
}

// PreAuthClose 预授权关闭
func (s *PreAuthCloseService) PreAuthClose(request *common.PreAuthCloseRequest) (*common.PreAuthCloseResponse, error) {
	response := common.NewPreAuthCloseResponse()
	err := s.Post(request, response, "/open/trans/preauthclose")
	if err != nil {
		return nil, err
	}
	return response, nil
}
